package hmvictor.jpql.types;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.JComponent;
import org.jdesktop.swingx.JXDatePicker;

/**
 *
 * @author Victor
 */
public class DateCalendarEditor implements Editor<Calendar>{
    private final JXDatePicker datePicker=new JXDatePicker();

    @Override
    public JComponent getComponent() {
        return datePicker;
    }
    

    @Override
    public Calendar getValue() {
        Calendar c=new GregorianCalendar();
        c.setTime(datePicker.getDate());
        return c;
    }

    @Override
    public JComponent getComponent(Object initValue) {
        datePicker.setDate(((Calendar)initValue).getTime());
        return datePicker;
    }
    
}
